#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;

// 91.15 %
class Solution
{
  public:
	int fourSumCount(vector<int> &A, vector<int> &B, vector<int> &C, vector<int> &D)
	{
		unordered_map<int, int> record;
		for (int i = 0; i < C.size(); i++)
		{
			for (int j = 0; j < D.size(); j++)
			{
				record[C[i] + D[j]]++;
			}
		}
		int res = 0;
		for (int i = 0; i < A.size(); i++)
		{
			for (int j = 0; j < B.size(); j++)
			{
				if (record.find(0 - A[i] - B[j]) != record.end())
				{
					res += record[0 - A[i] - B[j]];
				}
			}
		}
		return res;
	}
};

int main()
{
	int Aarr[] = {1, 2};
	int Barr[] = {-2, -1};
	int Carr[] = {-1, 2};
	int Darr[] = {0, 2};
	int la = sizeof(Aarr) / sizeof(Aarr[0]);
	int lb = sizeof(Barr) / sizeof(Barr[0]);
	int lc = sizeof(Carr) / sizeof(Carr[0]);
	int ld = sizeof(Darr) / sizeof(Darr[0]);
	vector<int> A(Aarr, Aarr + la);
	vector<int> B(Barr, Barr + lb);
	vector<int> C(Carr, Carr + lc);
	vector<int> D(Darr, Darr + ld);
	cout << Solution().fourSumCount(A, B, C, D) << endl;
	return 0;
}
